<?php
session_start();
?>
<html>
<head>
<?php
include ('head.php');

?>
<script>
function loadXMLDocTT1(str)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		$('#pro6').show(0,0,0);
		$('#pro7').hide(10,0,0);
		$('#pro8').hide(0,0,0);
		$('#pro9').hide(0,0,0);
		$('#pro10').hide(0,0,0);
    document.getElementById("pro6").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","httt.php?q="+str,true);
xmlhttp.send();
}
function loadXMLDocTT2(str)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		$('#pro6').hide(10,0,0);
		$('#pro7').show(10,0,0);
		$('#pro8').hide(0,0,0);
		$('#pro9').hide(0,0,0);
		$('#pro10').hide(0,0,0);
    document.getElementById("pro7").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","httt.php?q="+str,true);
xmlhttp.send();
}
function loadXMLDocTT3(str)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		$('#pro6').hide(0,0,0);
		$('#pro7').hide(0,0,0);
		$('#pro8').show(0,0,0);
		$('#pro9').hide(0,0,0);
		$('#pro10').hide(0,0,0);
    document.getElementById("pro8").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","httt.php?q="+str,true);
xmlhttp.send();
}
function loadXMLDocTT4(str)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		$('#pro6').hide(0,0,0);
		$('#pro7').hide(0,0,0);
		$('#pro8').hide(0,0,0);
		$('#pro9').show(0,0,0);
		$('#pro10').hide(0,0,0);
    document.getElementById("pro9").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","httt.php?q="+str,true);
xmlhttp.send();
}
function loadXMLDocTT5(str)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		$('#pro6').hide(0,0,0);
		$('#pro7').hide(0,0,0);
		$('#pro8').hide(0,0,0);
		$('#pro9').hide(0,0,0);
		$('#pro10').show(0,0,0);
    document.getElementById("pro10").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","httt.php?q="+str,true);
xmlhttp.send();
}


</script>
</head>

<body>
		
<?php
include ('dbcon.php');
include ('webtitle.php');
include ('topbannermenu.php');
include ('leftmenu.php');
include ('rightmenu.php');

?>	
   
  <div id = "divMid">
      <div id = "pro4">
        <center>
       
<font color="#0000CC"> <br><h1>THANH TOÁN</h1></font>
<?php 
   
  
 
?>
<?php

$ok=1;
if(isset($_SESSION['DT']))
{
 foreach($_SESSION['DT'] as $k => $v)
 {
  if(isset($k))
  {
   $ok=2;
  }
 }
}
if($ok == 2)
{

   echo "<form action='thanhcong.php' method='post'>";
   echo '<div id = "mheader">
		<span>
        Thông Tin Sản Phẩm 
        </span>
		</div>';
		echo "<br>";
	
   foreach($_SESSION['DT'] as $key=>$value)
   {
    $item[]=$key;
   }
   $str=implode(",",$item);
   $query=mysql_query("select * from sanpham where MaSP in ($str)");
   $total = 0;
   $id = "";
   echo "<table border='1' align='center' width = '80%'>";
   echo "<tr align='center'>  <td> Tên Sản Phẩm </td>	<td> Đơn Giá  </td>	<td> Số Lượng </td>	<td> Thành Tiền </td></tr>";
   while($row=mysql_fetch_array($query))
   {
	   echo "<tr align='center'>";
	   $id  = $row[0];
   
   echo "<td> $row[1] </td>";
   echo "<td>". number_format($row[3],0)."</td>";
   echo "<td> {$_SESSION['DT'][$id]} </td> ";
   echo "<td>". number_format($_SESSION['DT'][$row[0]]*$row[3],0)." </td>";
   $total+=$_SESSION['DT'][$row[0]]*$row[3];
   echo"</tr>";
   }
   echo"<tr align='right'><td colspan='4'> Tổng Cộng : ". number_format($total,0)."</td></tr></table> ";
   echo "<br>";
   echo "<div class = 'pro1' align = 'center'>";
	echo '<div id = "mheader">
		<span>
        Thông Tin Đặt Hàng
        </span>
		</div>';
		echo"<br>";
		echo "<form action='thanhcong.php' method = 'post'>";
		echo "<table border=0 width = '100%' >";
		echo "<tr><td align = 'right' width ='50%'>";
		echo "Họ tên (<font color='#FF0000'> * </font> ) :</td> <td> <input type = 'text' name = 'tbx_hoten' id = 'tbx_hoten'/> </td></tr>";
		echo "<tr><td align = 'right' width ='50%'>";
		echo "Email (<font color='#FF0000'> * </font> ) :</td> <td> <input type = 'text' name = 'tbx_email' id = 'tbx_email'/> </td></tr>";
		echo "<tr><td align = 'right' width ='50%'>";
		echo "Điện Thoại (<font color='#FF0000'> * </font> ) :</td> <td> <input type = 'text' name = 'tbx_dienthoai' id = 'tbx_dienthoai'/> </td></tr>";
		echo "<tr><td align = 'right' width ='50%'>";
		echo "Địa chỉ người đặt hàng (<font color='#FF0000'> * </font> ) :</td> <td> <input type = 'text' name = 'tbx_diachikh' id = 'tbx_diachikh' value =' '/> </td></tr>";
		echo "<tr><td align = 'right' width ='50%'>";
		echo "Ghi Chú :</td> <td> <textarea style='width:400px; height:80px; name='note' id='note' value = ' '></textarea> </td></tr>";
		echo "</table>";
		echo "</div>";
  
  echo "<div class = 'pro1' align = 'center'>";
	echo '<div id = "mheader">
		<span>
        Hình Thức Thanh Toán
        </span>
		</div>';
		echo "</div>";
		
  echo "<br> <table align='center' border = '0' width = '80%'>
  <tr align='left'> <td><br> <input type ='radio' name = 'httt' value = '1' onclick = 'loadXMLDocTT1(this.value)' > Thanh Toán Tiền Mặt </td> </tr>
  <tr align=<'center'> <td> <div id = 'pro6'></div> </td></tr>
  <tr align='left'> <td><br> <input type ='radio' name = 'httt' value = '2' onclick = 'loadXMLDocTT2(this.value)'> Thanh Toán Bằng Thẻ </td> </tr>
  <tr align=<'center'> <td> <div id = 'pro7'></div> </td></tr>
  <tr align='left'> <td><br> <input type ='radio' name = 'httt' value = '3' onclick = 'loadXMLDocTT3(this.value)'> Chuyển Khoản </td> </tr>
  <tr align=<'center'> <td> <div id = 'pro8'></div> </td></tr>
  <tr align='left'> <td><br> <input type ='radio' name = 'httt' value = '4' onclick = 'loadXMLDocTT4(this.value)' > Thanh Toán Qua Bưu Điện  </td> </tr>
  <tr align=<'center'> <td> <div id = 'pro9'></div> </td></tr>
  <tr align='left'> <td><br> <input type ='radio' name = 'httt' value = '5' onclick = 'loadXMLDocTT5(this.value)' > Thanh Toán Trực Tuyến  </td> </tr>
  <tr align=<'center'> <td> <div id = 'pro10'></div> </td></tr>
</table>   ";

 	echo "<br><br>";	
   	echo "<table width='300px' align='center' border=0>";
	echo "<tr> <td align = 'left'>";
	echo "<input type = 'submit' value = ' Xác Nhận ' class = 'css'name = 'btn_ok' id = 'btn_ok' /> </td>";
	echo "</form>";
	echo "<form action='thanhtoan2.php' method ='post' >";
	echo "<td align='right'> <input type = 'submit' value = ' Thanh Toán Bằng Tài Khoản TPD ' class = 'css'name = 'btn_ok' id = 'btn_ok' /> </td>";
	echo "</tr></table></form>";
	
	 echo "</div>";
}?>
  </div>

		<div class="clr"></div>
		<?php 
		include ('footer.php');
		?>
</body>
</html>

